﻿# // ***************************************************************************
# // 
# // Copyright (c) Scriptimus Ex Machina.  All rights reserved.
# // 
# // Microsoft Deployment Toolkit Support Script
# //
# // File:      ZTIDesktopBackground.ps1
# // 
# // Version:   1.00 
# // 
# // Purpose:   Applys a BGInfo Desktop Background
# // 
# // ***************************************************************************

<#
.Synopsis
   Applys a BGInfo Desktop Background
.DESCRIPTION
   The ZTIDesktopBackground.ps1 script copys the BGInfo.exe and Desktop.bgi files to C:\Program Files\BGInfo then creates a scheduled task to execute at each logon and execute it immediately.

.NOTES
   Author: Andrew Barnes
   Version: 1.0
   Created: 19 February 2013
   Last updated: 19 February 2013
   Website: http:\\scriptimus.wordpress.com

#>

Param(
$Path = $env:ProgramFiles +'\BGInfo'
)

Begin {}

Process {

    # Install BGInfo
    if (!(Test-Path $Path))
    {
    New-Item -ItemType Directory -Path $Path  
    Copy-Item -Path ($TSEnv:DeployRoot +"\Tools\x86\BGInfo.exe") -Destination $Path
    Copy-Item -Path ($TSEnv:DeployRoot +"\Scripts\Desktop.BGI") -Destination $Path

    }

    # Create Scheduled Task

    Write-Host "Creating Scheduled task"
    
    [String]$Task = cmd /c 'schtasks /create /tn "Desktop Background" /tr "\"C:\Program Files\BGInfo\Bginfo.exe\" \"C:\Program Files\BGInfo\Desktop.bgi\" /nolicprompt /timer:0" /sc onlogon'

    # Run BGInfo
    schtasks /run /tn "Desktop Background"

}

End{}
